package com.shop2cn.wxcomponent.testcase;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.shop2cn.wxcomponent.parameter.AppCallBackBean;
import com.shop2cn.wxcomponent.service.AppCallBackCall;
import com.ymt.core.tool.FormatUtil;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
import com.ymttest.business.service.PayGateWayCallService;
import com.ymttest.business.service.WxComponentService;
import com.ymttest.database.model.Auditrecord;
import com.ymttest.database.model.Mchapp;
import com.ymttest.database.model.Platformconfig;
import com.ymttest.database.model.mch_info;
import com.ymttest.database.sqlwapper.godmch.DefGodMchWapper;
import com.ymttest.utils.TestDataManager;
import com.ymttest.utils.YMTDateUtil;
/**
*审核通知
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_AppCallBack{
	private static AppCallBackBean AppCallBackBean;
	private static AppCallBackCall AppCallBackCall;
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("审核通知回调");
	}

	@Before
	public void caseUp() {
		AppCallBackBean=new AppCallBackBean();
		AppCallBackCall=new AppCallBackCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(AppCallBackCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_AppCallBack_001() {
		Logger.start(true,"app提审通知-审核成功");
		try {
			String timestamp=String.valueOf(YMTDateUtil.getDate().getTime()/1000);
			Integer mchid=3001;
			WxComponentService.deleteMchinfo(mchid);
			String appid = WxComponentService.ConfirmAuthorization(mchid);
			WxComponentService.AuthorizationCallBack(appid, "authorized");
			WxComponentService.ApplyCharge(mchid);
			WxComponentService.ChargeNotify(mchid);
			WxComponentService.ConfirmAuditMchApp(mchid);
			Platformconfig platf = new DefGodMchWapper().selectPlatformconfigByExample().get(0);
//			审核通过<xml>
//			  <ToUserName><![CDATA[gh_fb9688c2a4b2]]></ToUserName>
//			  <FromUserName><![CDATA[od1P50M-fNQI5Gcq-trm4a7apsU8]]></FromUserName>
//			  <CreateTime>1488856741</CreateTime>
//			  <MsgType><![CDATA[event]]></MsgType>
//			  <Event><![CDATA[weapp_audit_success]]></Event>
//			  <SuccTime>1488856741</SuccTime>
//			</xml>
			AppCallBackBean.setToUserName("touname");
			AppCallBackBean.setFromUserName("funame");
			AppCallBackBean.setCreateTime(Long.valueOf(timestamp));
			AppCallBackBean.setSuccTime(Long.valueOf(timestamp));
			AppCallBackBean.setEvent("weapp_audit_success");
			AppCallBackBean.setMsgType("event");
			Map sendinfo=WxComponentService.getAppCallBackSend(AppCallBackBean);
//			Logger.debug(sendinfo);
			String signature=sendinfo.get("signature").toString();
			String mingwen=sendinfo.get("mingwen").toString();
			String nonce=sendinfo.get("nonce").toString();
			//api/{APPID}/callback?timestamp=1575973810&nonce=155395418&encrypt_type=aes&msg_signature=39e94b7cf31b636a010c0894918d4f0442f741f3
			String opurl2="api/"+appid+"/callback?timestamp="+timestamp+"&nonce="+nonce+"&encrypt_type=aes&msg_signature="+signature;
			AppCallBackCall=new AppCallBackCall(opurl2);
			AppCallBackCall.setData(mingwen);
			
			
			AppCallBackCall.callService();	
			Logger.verifyEquals("ok", AppCallBackCall.getReturnData(), "验证返回");
			String result2 =WxComponentService.decryptMsg(sendinfo.get("encrypt").toString(), platf.getPlatformAppId());
			System.out.println("解密后明文: " + result2);
			DefGodMchWapper DefGodMchWapper= new DefGodMchWapper();
			Mchapp mch = DefGodMchWapper.selectMchappByExample(mchid).get(0);
			Logger.verifyEquals(4, mch.getAppStatus(), "验证状态AppStatus");
//			Logger.verifyEquals(true,mch.getIsPublished(), "验证状态IsPublished"); 不验证发布状态
			Auditrecord auditrecord = DefGodMchWapper.selectAuditrecordByExample(mchid).get(0);
			Logger.debug(FormatUtil.beanToGSONString(auditrecord));
			//提审记录状态：0- 提审中，1- 审核通过，2- 审核失败，3-审核延后，4- 审核撤回
			Logger.verifyEquals(1, auditrecord.getAuditStatus(), "验证状态");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_AppCallBack_002() {
		Logger.start(true,"app提审通知-审核失败");
		try {
			String timestamp=String.valueOf(YMTDateUtil.getDate().getTime()/1000);
			Integer mchid=3002;
			WxComponentService.deleteMchinfo(mchid);
			String appid = WxComponentService.ConfirmAuthorization(mchid);
			WxComponentService.AuthorizationCallBack(appid, "authorized");
			WxComponentService.ApplyCharge(mchid);
			WxComponentService.ChargeNotify(mchid);
			WxComponentService.ConfirmAuditMchApp(mchid);
			Platformconfig platf = new DefGodMchWapper().selectPlatformconfigByExample().get(0);
//			审核通过<xml>
//			  <ToUserName><![CDATA[gh_fb9688c2a4b2]]></ToUserName>
//			  <FromUserName><![CDATA[od1P50M-fNQI5Gcq-trm4a7apsU8]]></FromUserName>
//			  <CreateTime>1488856591</CreateTime>
//			  <MsgType><![CDATA[event]]></MsgType>
//			  <Event><![CDATA[weapp_audit_fail]]></Event>
//			  <Reason><![CDATA[1:账号信息不符合规范:<br>(1):包含色情因素<br>2:服务类目"金融业-保险_"与你提交代码审核时设置的功能页面内容不一致:<br>(1):功能页面设置的部分标签不属于所选的服务类目范围。<br>(2):功能页面设置的部分标签与该页面内容不相关。<br>]]></Reason>
//			  <FailTime>1488856591</FailTime>
//			  <ScreenShot>xxx|yyy|zzz</ScreeenShot>
//			</xml>
			AppCallBackBean.setToUserName("touname");
			AppCallBackBean.setFromUserName("funame");
			AppCallBackBean.setCreateTime(Long.valueOf(timestamp));
			AppCallBackBean.setFailTime(Long.valueOf(timestamp));
			AppCallBackBean.setEvent("weapp_audit_fail");
			AppCallBackBean.setMsgType("event");
			AppCallBackBean.setReason("<![CDATA[1:账号信息不符合规范:<br>(1):包含色情因素<br>2:服务类目\"金融业-保险_\"与你提交代码审核时设置的功能页面内容不一致:<br>(1):功能页面设置的部分标签不属于所选的服务类目范围。<br>(2):功能页面设置的部分标签与该页面内容不相关。<br>]]>");
			AppCallBackBean.setScreenShot("aaa|bb");
			Map sendinfo=WxComponentService.getAppCallBackSend(AppCallBackBean);
//			Logger.debug(sendinfo);
			String signature=sendinfo.get("signature").toString();
			String mingwen=sendinfo.get("mingwen").toString();
			String nonce=sendinfo.get("nonce").toString();
			//api/{APPID}/callback?timestamp=1575973810&nonce=155395418&encrypt_type=aes&msg_signature=39e94b7cf31b636a010c0894918d4f0442f741f3
			String opurl2="api/"+appid+"/callback?timestamp="+timestamp+"&nonce="+nonce+"&encrypt_type=aes&msg_signature="+signature;
			AppCallBackCall=new AppCallBackCall(opurl2);
			AppCallBackCall.setData(mingwen);
			AppCallBackCall.callService();	
			Logger.verifyEquals("ok", AppCallBackCall.getReturnData(), "验证返回");
			String result2 =WxComponentService.decryptMsg(sendinfo.get("encrypt").toString(), platf.getPlatformAppId());
			System.out.println("解密后明文: " + result2);
			
			DefGodMchWapper DefGodMchWapper= new DefGodMchWapper();
			//小程序状态 0：未授权 1:已授权 待提审 2:审核中 3:审核失败 4:审核成功待发布
			Logger.verifyEquals(3, DefGodMchWapper.selectMchappByExample(mchid).get(0).getAppStatus(), "验证状态");
			Auditrecord auditrecord = new DefGodMchWapper().selectAuditrecordByExample(mchid).get(0);
			Logger.debug(FormatUtil.beanToGSONString(auditrecord));
			Logger.verifyIsContains(auditrecord.getReason(),AppCallBackBean.getReason(),  "验证Reason");
			Logger.debug(FormatUtil.beanToGSONString(auditrecord));
			//提审记录状态：0- 提审中，1- 审核通过，2- 审核失败，3-审核延后，4- 审核撤回
			Logger.verifyEquals(2, auditrecord.getAuditStatus(), "验证状态");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_AppCallBack_003() {
		Logger.start(true,"app提审通知-审核延期");
		try {
			String timestamp=String.valueOf(YMTDateUtil.getDate().getTime()/1000);
			Integer mchid=3002;
			WxComponentService.deleteMchinfo(mchid);
			String appid = WxComponentService.ConfirmAuthorization(mchid);
			WxComponentService.AuthorizationCallBack(appid, "authorized");
			WxComponentService.ApplyCharge(mchid);
			WxComponentService.ChargeNotify(mchid);
			WxComponentService.ConfirmAuditMchApp(mchid);
			Platformconfig platf = new DefGodMchWapper().selectPlatformconfigByExample().get(0);
//			审核通过<xml>
//			  <ToUserName><![CDATA[gh_fb9688c2a4b2]]></ToUserName>
//			  <FromUserName><![CDATA[od1P50M-fNQI5Gcq-trm4a7apsU8]]></FromUserName>
//			  <CreateTime>1488856591</CreateTime>
//			  <MsgType><![CDATA[event]]></MsgType>
//			  <Event><![CDATA[weapp_audit_fail]]></Event>
//			  <Reason><![CDATA[1:账号信息不符合规范:<br>(1):包含色情因素<br>2:服务类目"金融业-保险_"与你提交代码审核时设置的功能页面内容不一致:<br>(1):功能页面设置的部分标签不属于所选的服务类目范围。<br>(2):功能页面设置的部分标签与该页面内容不相关。<br>]]></Reason>
//			  <FailTime>1488856591</FailTime>
//			  <ScreenShot>xxx|yyy|zzz</ScreeenShot>
//			</xml>
			AppCallBackBean.setToUserName("touname");
			AppCallBackBean.setFromUserName("funame");
			AppCallBackBean.setCreateTime(Long.valueOf(timestamp));
			AppCallBackBean.setDelayTime(Long.valueOf(timestamp));
			AppCallBackBean.setEvent("weapp_audit_delay");
			AppCallBackBean.setMsgType("event");
			AppCallBackBean.setReason("<![CDATA[1:账号信息不符合规范:<br>(1):包含色情因素<br>2:服务类目\"金融业-保险_\"与你提交代码审核时设置的功能页面内容不一致:<br>(1):功能页面设置的部分标签不属于所选的服务类目范围。<br>(2):功能页面设置的部分标签与该页面内容不相关。<br>]]>");
			AppCallBackBean.setScreenShot("aaa|bb");
			Map sendinfo=WxComponentService.getAppCallBackSend(AppCallBackBean);
//			Logger.debug(sendinfo);
			String signature=sendinfo.get("signature").toString();
			String mingwen=sendinfo.get("mingwen").toString();
			String nonce=sendinfo.get("nonce").toString();
			//api/{APPID}/callback?timestamp=1575973810&nonce=155395418&encrypt_type=aes&msg_signature=39e94b7cf31b636a010c0894918d4f0442f741f3
			String opurl2="api/"+appid+"/callback?timestamp="+timestamp+"&nonce="+nonce+"&encrypt_type=aes&msg_signature="+signature;
			AppCallBackCall=new AppCallBackCall(opurl2);
			AppCallBackCall.setData(mingwen);
			AppCallBackCall.callService();	
			Logger.verifyEquals("ok", AppCallBackCall.getReturnData(), "验证返回");
			String result2 =WxComponentService.decryptMsg(sendinfo.get("encrypt").toString(), platf.getPlatformAppId());
			System.out.println("解密后明文: " + result2);
			
			DefGodMchWapper DefGodMchWapper= new DefGodMchWapper();
			//小程序状态 0：未授权 1:已授权 待提审 2:审核中 3:审核失败 4:审核成功待发布
			Logger.verifyEquals(2, DefGodMchWapper.selectMchappByExample(mchid).get(0).getAppStatus(), "验证状态");
			Auditrecord auditrecord = new DefGodMchWapper().selectAuditrecordByExample(mchid).get(0);
			Logger.debug(FormatUtil.beanToGSONString(auditrecord));
			Logger.verifyIsContains(auditrecord.getReason(),AppCallBackBean.getReason(),  "验证Reason");
			Logger.debug(FormatUtil.beanToGSONString(auditrecord));
			//提审记录状态：0- 提审中，1- 审核通过，2- 审核失败，3-审核延后，4- 审核撤回
			Logger.verifyEquals(3, auditrecord.getAuditStatus(), "验证状态");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	//名称审核 wxa_nickname_audit
	
	
//	<xml>
//	<ToUserName><![CDATA[gh_fxxxxxxxa4b2]]></ToUserName>
//	<FromUserName><![CDATA[odxxxxM-xxxxxxxx-trm4a7apsU8]]></FromUserName>
//	<CreateTime>1488800000</CreateTime>
//	<MsgType><![CDATA[event]]></MsgType>
//	<Event><![CDATA[wxa_nickname_audit]]></Event>
//	<ret>2</ret>
//	<nickname>昵称</nickname>
//	<reason>驳回原因</reason>
//</xml>
	@Test
	@Category({P1.class})
	@TestCase
	@Ignore
	//名称审核不处理-曹二信-20191219
	public void Tc_AppCallBack_004() {
		Logger.start(true,"app名称审核通知-审核成功");
		try {
			String timestamp=String.valueOf(YMTDateUtil.getDate().getTime()/1000);
			Integer mchid=3004;
			WxComponentService.deleteMchinfo(mchid);
			String appid = WxComponentService.ConfirmAuthorization(mchid);
			WxComponentService.AuthorizationCallBack(appid, "authorized");
			WxComponentService.ApplyCharge(mchid);
			WxComponentService.ChargeNotify(mchid);
			Platformconfig platf = new DefGodMchWapper().selectPlatformconfigByExample().get(0);
//			审核通过<xml>
//			  <ToUserName><![CDATA[gh_fb9688c2a4b2]]></ToUserName>
//			  <FromUserName><![CDATA[od1P50M-fNQI5Gcq-trm4a7apsU8]]></FromUserName>
//			  <CreateTime>1488856591</CreateTime>
//			  <MsgType><![CDATA[event]]></MsgType>
//			  <Event><![CDATA[weapp_audit_fail]]></Event>
//			  <Reason><![CDATA[1:账号信息不符合规范:<br>(1):包含色情因素<br>2:服务类目"金融业-保险_"与你提交代码审核时设置的功能页面内容不一致:<br>(1):功能页面设置的部分标签不属于所选的服务类目范围。<br>(2):功能页面设置的部分标签与该页面内容不相关。<br>]]></Reason>
//			  <FailTime>1488856591</FailTime>
//			  <ScreenShot>xxx|yyy|zzz</ScreeenShot>
//			</xml>
			AppCallBackBean.setToUserName("touname");
			AppCallBackBean.setFromUserName("funame");
			AppCallBackBean.setCreateTime(Long.valueOf(timestamp));
			AppCallBackBean.setFailTime(Long.valueOf(timestamp));
			AppCallBackBean.setEvent("wxa_nickname_audit");
			AppCallBackBean.setMsgType("event");
			AppCallBackBean.setNickname("昵称"+TestDataManager.getRandomNum(2));
			AppCallBackBean.setRet(3);
			AppCallBackBean.setReason("<![CDATA[1:账号信息不符合规范:<br>(1):包含色情因素<br>2:服务类目\"金融业-保险_\"与你提交代码审核时设置的功能页面内容不一致:<br>(1):功能页面设置的部分标签不属于所选的服务类目范围。<br>(2):功能页面设置的部分标签与该页面内容不相关。<br>]]>");
			AppCallBackBean.setScreenShot("aaa|bb");
			Map sendinfo=WxComponentService.getAppCallBackSend(AppCallBackBean);
//			Logger.debug(sendinfo);
			String signature=sendinfo.get("signature").toString();
			String mingwen=sendinfo.get("mingwen").toString();
			String nonce=sendinfo.get("nonce").toString();
			//api/{APPID}/callback?timestamp=1575973810&nonce=155395418&encrypt_type=aes&msg_signature=39e94b7cf31b636a010c0894918d4f0442f741f3
			String opurl2="api/"+appid+"/callback?timestamp="+timestamp+"&nonce="+nonce+"&encrypt_type=aes&msg_signature="+signature;
			AppCallBackCall=new AppCallBackCall(opurl2);
			AppCallBackCall.setData(mingwen);
			AppCallBackCall.callService();	
			Logger.verifyEquals("ok", AppCallBackCall.getReturnData(), "验证返回");
			String result2 =WxComponentService.decryptMsg(sendinfo.get("encrypt").toString(), platf.getPlatformAppId());
			System.out.println("解密后明文: " + result2);
			 Mchapp app = new DefGodMchWapper().selectMchappByExample(mchid).get(0);
			Logger.debug(FormatUtil.beanToGSONString(app));
			Logger.verifyEquals(AppCallBackBean.getNickname(), app.getAppName(), "验证nickname");
			Logger.verifyEquals(AppCallBackBean.getRet(), app.getAppNameStatus(), "验证AppNameStatus");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	@Ignore
	public void Tc_AppCallBack_005() {
		Logger.start(true,"app名称审核通知-审核失败");
		try {
			String timestamp=String.valueOf(YMTDateUtil.getDate().getTime()/1000);
			Integer mchid=3005;
			WxComponentService.deleteMchinfo(mchid);
			String appid = WxComponentService.ConfirmAuthorization(mchid);
			WxComponentService.AuthorizationCallBack(appid, "authorized");
			Platformconfig platf = new DefGodMchWapper().selectPlatformconfigByExample().get(0);
//			审核通过<xml>
//			  <ToUserName><![CDATA[gh_fb9688c2a4b2]]></ToUserName>
//			  <FromUserName><![CDATA[od1P50M-fNQI5Gcq-trm4a7apsU8]]></FromUserName>
//			  <CreateTime>1488856591</CreateTime>
//			  <MsgType><![CDATA[event]]></MsgType>
//			  <Event><![CDATA[weapp_audit_fail]]></Event>
//			  <Reason><![CDATA[1:账号信息不符合规范:<br>(1):包含色情因素<br>2:服务类目"金融业-保险_"与你提交代码审核时设置的功能页面内容不一致:<br>(1):功能页面设置的部分标签不属于所选的服务类目范围。<br>(2):功能页面设置的部分标签与该页面内容不相关。<br>]]></Reason>
//			  <FailTime>1488856591</FailTime>
//			  <ScreenShot>xxx|yyy|zzz</ScreeenShot>
//			</xml>
			AppCallBackBean.setToUserName("touname");
			AppCallBackBean.setFromUserName("funame");
			AppCallBackBean.setCreateTime(Long.valueOf(timestamp));
			AppCallBackBean.setFailTime(Long.valueOf(timestamp));
			AppCallBackBean.setEvent("wxa_nickname_audit");
			AppCallBackBean.setMsgType("event");
			AppCallBackBean.setNickname("昵称"+TestDataManager.getRandomNum(2));
			AppCallBackBean.setRet(2);
			AppCallBackBean.setReason("<![CDATA[1:账号信息不符合规范:<br>(1):包含色情因素<br>2:服务类目\"金融业-保险_\"与你提交代码审核时设置的功能页面内容不一致:<br>(1):功能页面设置的部分标签不属于所选的服务类目范围。<br>(2):功能页面设置的部分标签与该页面内容不相关。<br>]]>");
			AppCallBackBean.setScreenShot("aaa|bb");
			Map sendinfo=WxComponentService.getAppCallBackSend(AppCallBackBean);
//			Logger.debug(sendinfo);
			String signature=sendinfo.get("signature").toString();
			String mingwen=sendinfo.get("mingwen").toString();
			String nonce=sendinfo.get("nonce").toString();
			//api/{APPID}/callback?timestamp=1575973810&nonce=155395418&encrypt_type=aes&msg_signature=39e94b7cf31b636a010c0894918d4f0442f741f3
			String opurl2="api/"+appid+"/callback?timestamp="+timestamp+"&nonce="+nonce+"&encrypt_type=aes&msg_signature="+signature;
			AppCallBackCall=new AppCallBackCall(opurl2);
			AppCallBackCall.setData(mingwen);
			AppCallBackCall.callService();	
			Logger.verifyEquals("ok", AppCallBackCall.getReturnData(), "验证返回");
			String result2 =WxComponentService.decryptMsg(sendinfo.get("encrypt").toString(), platf.getPlatformAppId());
			System.out.println("解密后明文: " + result2);
			 Mchapp app = new DefGodMchWapper().selectMchappByExample(mchid).get(0);
			Logger.debug(FormatUtil.beanToGSONString(app));
			Logger.verifyEquals(AppCallBackBean.getNickname(), app.getAppName(), "验证nickname");
			Logger.verifyEquals(AppCallBackBean.getReason(), app.getAppNameStatus(), "验证AppNameStatus");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_AppCallBack_006() {
		Logger.start(true,"app提审通知-无此数据");
		try {
			String timestamp=String.valueOf(YMTDateUtil.getDate().getTime()/1000);
			Integer mchid=1;
			WxComponentService.deleteMchinfo(mchid);
			AppCallBackBean.setToUserName("touname");
			AppCallBackBean.setFromUserName("funame");
			AppCallBackBean.setCreateTime(Long.valueOf(timestamp));
			AppCallBackBean.setDelayTime(Long.valueOf(timestamp));
			AppCallBackBean.setEvent("weapp_audit_delay");
			AppCallBackBean.setMsgType("event");
//			AppCallBackBean.setReason("<![CDATA[1:账号信息不符合规范:<br>(1):包含色情因素<br>2:服务类目\"金融业-保险_\"与你提交代码审核时设置的功能页面内容不一致:<br>(1):功能页面设置的部分标签不属于所选的服务类目范围。<br>(2):功能页面设置的部分标签与该页面内容不相关。<br>]]>");
			AppCallBackBean.setScreenShot("aaa|bb");
			Map sendinfo=WxComponentService.getAppCallBackSend(AppCallBackBean);
//			Logger.debug(sendinfo);
			String signature=sendinfo.get("signature").toString();
			String mingwen=sendinfo.get("mingwen").toString();
			String nonce=sendinfo.get("nonce").toString();
			//api/{APPID}/callback?timestamp=1575973810&nonce=155395418&encrypt_type=aes&msg_signature=39e94b7cf31b636a010c0894918d4f0442f741f3
			String opurl2="api/"+1+"/callback?timestamp="+timestamp+"&nonce="+nonce+"&encrypt_type=aes&msg_signature="+signature;
			AppCallBackCall=new AppCallBackCall(opurl2);
			AppCallBackCall.setData(mingwen);
			AppCallBackCall.callService();	
			Logger.verifyEquals("ok", AppCallBackCall.getReturnData(), "验证返回");
			//查看日志 无此记录
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	@Ignore
	//线上操作
	public void Tc_AppCallBack_007() {
		Logger.start(true,"app提审通知-审核成功-release失败");
		try {
			String timestamp=String.valueOf(YMTDateUtil.getDate().getTime()/1000);
			Integer mchid=3001;
			WxComponentService.deleteMchinfo(mchid);
			String appid = WxComponentService.ConfirmAuthorization(mchid);
			WxComponentService.AuthorizationCallBack(appid, "authorized");
			WxComponentService.ConfirmAuditMchApp(mchid);
			Platformconfig platf = new DefGodMchWapper().selectPlatformconfigByExample().get(0);
//			审核通过<xml>
//			  <ToUserName><![CDATA[gh_fb9688c2a4b2]]></ToUserName>
//			  <FromUserName><![CDATA[od1P50M-fNQI5Gcq-trm4a7apsU8]]></FromUserName>
//			  <CreateTime>1488856741</CreateTime>
//			  <MsgType><![CDATA[event]]></MsgType>
//			  <Event><![CDATA[weapp_audit_success]]></Event>
//			  <SuccTime>1488856741</SuccTime>
//			</xml>
			AppCallBackBean.setToUserName("touname");
			AppCallBackBean.setFromUserName("funame");
			AppCallBackBean.setCreateTime(Long.valueOf(timestamp));
			AppCallBackBean.setSuccTime(Long.valueOf(timestamp));
			AppCallBackBean.setEvent("weapp_audit_success");
			AppCallBackBean.setMsgType("event");
			Map sendinfo=WxComponentService.getAppCallBackSend(AppCallBackBean);
//			Logger.debug(sendinfo);
			String signature=sendinfo.get("signature").toString();
			String mingwen=sendinfo.get("mingwen").toString();
			String nonce=sendinfo.get("nonce").toString();
			//api/{APPID}/callback?timestamp=1575973810&nonce=155395418&encrypt_type=aes&msg_signature=39e94b7cf31b636a010c0894918d4f0442f741f3
			String opurl2="api/"+appid+"/callback?timestamp="+timestamp+"&nonce="+nonce+"&encrypt_type=aes&msg_signature="+signature;
			AppCallBackCall=new AppCallBackCall(opurl2);
			AppCallBackCall.setData(mingwen);
			
			
			Map m=new HashMap();
//			mock:mock-enable
			m.put("mock", "mock-enable");
			m.put("mockId-1", TestDataManager.getRandomUUID().toString());
			m.put("mockApi-1", "wxcomponent-release-Fail");
			PayGateWayCallService.addMock(AppCallBackCall, m);
			
			AppCallBackCall.callService();	
			Logger.verifyEquals("ok", AppCallBackCall.getReturnData(), "验证返回");
			String result2 =WxComponentService.decryptMsg(sendinfo.get("encrypt").toString(), platf.getPlatformAppId());
			System.out.println("解密后明文: " + result2);
			DefGodMchWapper DefGodMchWapper= new DefGodMchWapper();
			Mchapp mch = DefGodMchWapper.selectMchappByExample(mchid).get(0);
			Logger.verifyEquals(4, mch.getAppStatus(), "验证状态AppStatus");
			Logger.verifyEquals(false,mch.getIsPublished(), "验证状态IsPublished");
			Auditrecord auditrecord = DefGodMchWapper.selectAuditrecordByExample(mchid).get(0);
			Logger.debug(FormatUtil.beanToGSONString(auditrecord));
			//提审记录状态：1- 提审中，2- 审核通过，3- 审核失败，4-审核延后，5- 审核撤回
			Logger.verifyEquals(2, auditrecord.getAuditStatus(), "验证状态");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_AppCallBack_008() {
		Logger.start(true,"app提审通知-未付款");
		try {
			String timestamp=String.valueOf(YMTDateUtil.getDate().getTime()/1000);
			Integer mchid=3008;
			WxComponentService.deleteMchinfo(mchid);
			String appid = WxComponentService.ConfirmAuthorization(mchid);
			WxComponentService.AuthorizationCallBack(appid, "authorized");
			WxComponentService.ConfirmAuditMchApp(mchid);
			Platformconfig platf = new DefGodMchWapper().selectPlatformconfigByExample().get(0);
//			审核通过<xml>
//			  <ToUserName><![CDATA[gh_fb9688c2a4b2]]></ToUserName>
//			  <FromUserName><![CDATA[od1P50M-fNQI5Gcq-trm4a7apsU8]]></FromUserName>
//			  <CreateTime>1488856741</CreateTime>
//			  <MsgType><![CDATA[event]]></MsgType>
//			  <Event><![CDATA[weapp_audit_success]]></Event>
//			  <SuccTime>1488856741</SuccTime>
//			</xml>
			AppCallBackBean.setToUserName("touname");
			AppCallBackBean.setFromUserName("funame");
			AppCallBackBean.setCreateTime(Long.valueOf(timestamp));
			AppCallBackBean.setSuccTime(Long.valueOf(timestamp));
			AppCallBackBean.setEvent("weapp_audit_success");
			AppCallBackBean.setMsgType("event");
			Map sendinfo=WxComponentService.getAppCallBackSend(AppCallBackBean);
//			Logger.debug(sendinfo);
			String signature=sendinfo.get("signature").toString();
			String mingwen=sendinfo.get("mingwen").toString();
			String nonce=sendinfo.get("nonce").toString();
			//api/{APPID}/callback?timestamp=1575973810&nonce=155395418&encrypt_type=aes&msg_signature=39e94b7cf31b636a010c0894918d4f0442f741f3
			String opurl2="api/"+appid+"/callback?timestamp="+timestamp+"&nonce="+nonce+"&encrypt_type=aes&msg_signature="+signature;
			AppCallBackCall=new AppCallBackCall(opurl2);
			AppCallBackCall.setData(mingwen);
			
			
			AppCallBackCall.callService();	
			Logger.verifyEquals("ok", AppCallBackCall.getReturnData(), "验证返回");
			String result2 =WxComponentService.decryptMsg(sendinfo.get("encrypt").toString(), platf.getPlatformAppId());
			System.out.println("解密后明文: " + result2);
			DefGodMchWapper DefGodMchWapper= new DefGodMchWapper();
			Mchapp mch = DefGodMchWapper.selectMchappByExample(mchid).get(0);
			Logger.verifyEquals(1, mch.getAppStatus(), "验证状态AppStatus");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}